#coding=utf-8

module Aio::Text
  class LineString < String
    class Mismatch < StandardError; end

    attr_accessor :content, :line

    include Aio::Ui::Verbose

    # 获得区块
    # 并且获得所在的行数
    def match_block(reg, cont, line)
      block = Block.new(reg.match(self))
      #raise Mismatch.new, "reg: #{reg}\nstr: #{self.to_s}" if block.nil?
      if block.nil?
        return false
      end

      block.content = cont
      block.line    = line

      yield block
    end


  end
end

